package com.koron.order.linepatrol.base.controller;

import com.github.pagehelper.PageInfo;
import com.koron.bean.base.Response;
import com.koron.bean.query.PageQuery;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.order.linepatrol.base.bean.po.PatrolEquipmentParamsPo;
import com.koron.order.linepatrol.base.service.PatrolEquipmentParamsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 巡视工单-巡视点设备下参数从表(PatrolEquipmentParams)表控制层
 *
 * @author zhouj
 * @since 2021-10-26 15:27:06
 */
@Api(tags = "线路巡视工单-巡视点设备下参数从表(PatrolEquipmentParams)")
@RestController("linePatrolEquipmentParamsController")
@RequestMapping("/linePatrolEquipmentParams/")
public class PatrolEquipmentParamsController {

    @Autowired
    private PatrolEquipmentParamsService linePatrolEquipmentParamsService;

    private String getCurrDs() {
        return ThreadLocalContext.get().getCurrDs();
    }

    @ApiOperation(value = "新增或修改巡视工单-巡视点设备下参数从表")
    @PostMapping("insertOrUpdate")
    public Response<String> insertOrUpdate(@RequestBody PatrolEquipmentParamsPo patrolEquipmentParams) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), linePatrolEquipmentParamsService, "insertOrUpdate", String.class, patrolEquipmentParams));
    }

    @ApiOperation(value = "新增巡视工单-巡视点设备下参数从表")
    @PostMapping("insert")
    public Response<Integer> insert(@RequestBody PatrolEquipmentParamsPo patrolEquipmentParams) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), linePatrolEquipmentParamsService, "insert", Integer.class, patrolEquipmentParams));
    }

    @ApiOperation(value = "批量新增巡视工单-巡视点设备下参数从表")
    @PostMapping("insertBatch")
    public Response<Integer> insertBatch(@RequestBody List<PatrolEquipmentParamsPo> patrolEquipmentParamsList) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), linePatrolEquipmentParamsService, "insertBatch", Integer.class, patrolEquipmentParamsList));
    }

    @ApiOperation(value = "根据id更新巡视工单-巡视点设备下参数从表")
    @PutMapping("update")
    public Response<Integer> update(@RequestBody PatrolEquipmentParamsPo patrolEquipmentParams) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), linePatrolEquipmentParamsService, "update", Integer.class, patrolEquipmentParams));
    }

    @ApiOperation(value = "根据id删除巡视工单-巡视点设备下参数从表")
    @DeleteMapping("deleteById")
    public Response<Integer> deleteById(String id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), linePatrolEquipmentParamsService, "deleteById", Integer.class, id));
    }

    @ApiOperation(value = "根据id查询巡视工单-巡视点设备下参数从表")
    @GetMapping("queryById")
    public Response<PatrolEquipmentParamsPo> queryById(String id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), linePatrolEquipmentParamsService, "queryById", PatrolEquipmentParamsPo.class, id));
    }

    @ApiOperation(value = "不分页查询巡视工单-巡视点设备下参数从表列表")
    @GetMapping("queryList")
    public Response<List> queryList(PatrolEquipmentParamsPo queryVo) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), linePatrolEquipmentParamsService, "queryList", List.class, queryVo));
    }

    @ApiOperation(value = "分页查询巡视工单-巡视点设备下参数从表列表")
    @GetMapping("queryPageList")
    public Response<PageInfo> queryPageList(PatrolEquipmentParamsPo queryPo, PageQuery pageQuery) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), linePatrolEquipmentParamsService, "queryPageList", PageInfo.class, queryPo, pageQuery));
    }

}
